package com.easychat.utils;

import com.easychat.entity.constants.Constants;
import jodd.util.StringUtil;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @author kyle.li
 * @version 1.0
 * @description: TODO
 * @date 2024/7/1 19:46
 */
public class StringTools {


    //生成账号随机数
    public static String getUserId(){
        return "U" + getRandomNumber(Constants.Length_11);
    }

    //生成数字随机数
    public static String getRandomNumber(Integer count){
        return RandomStringUtils.random(count, false, true);
    }

    //生成字符串随机数
    public static String getRandomString(Integer count){
        return RandomStringUtils.random(count, true, true);
    }

    //加密 md5
    public static final String encodeMd5(String originString){
        return StringUtils.isEmpty(originString) ? null : DigestUtils.md5Hex(originString);
    }

}
